﻿<%@ WebHandler Language="C#" Class="Training.Web.AjaxHandler.Loaddata.Administration.Catalog.PelatihanLoadHandler" %>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Text;

using Training.Library.DataAccess.Administration;
using Training.Library.DomainObject.Administration;
using Training.Library.DataAccess.Administration.Catalog;
using Training.Library.DomainObject.Administration.Catalog;

using Training.Library.Enum;
using Training.Web.Support;
using SIPO.Library.DataAccess.Administration.Catalog;
using SIPO.Library.DomainObject.Administration.Catalog;

using Newtonsoft.Json.Linq;

namespace Training.Web.AjaxHandler.Loaddata.Administration.Catalog
{

    public class PelatihanLoadHandler : Training.Web.BaseHandler
    {

        PelatihanRepo PelatihanDal = new PelatihanRepo(ConfigurationManager.ConnectionStrings["TrainingConn"].ConnectionString);
        PembicaraRepo PembicaraDal = new PembicaraRepo(ConfigurationManager.ConnectionStrings["TrainingConn"].ConnectionString);
        string MethodName = string.Empty;

        public override void ProcessRequest(HttpContext context)
        {
            base.ProcessRequest(context);

            StringBuilder sbProject = new StringBuilder();
            if (context.Request.Params["method"] != null)
                MethodName = context.Request.Params["method"];

            if (MethodName == "getbyid")
            {
                int pelatihanID = Convert.ToInt32(context.Request.Params["pelatihanID"].ToString());

                Pelatihan objPelatihan = PelatihanDal.GetById(pelatihanID);
                Pembicara objPembicara = PembicaraDal.GetById(Convert.ToInt32(objPelatihan.PembicaraID));

                sbProject.Append("{");
                sbProject.AppendFormat("  {0}NamaPelatihan{0}:{0}{1}{0}", "\"", objPelatihan.NamaPelatihan);
                sbProject.Append(",");
                sbProject.AppendFormat("  {0}TglPelatihan{0}:{0}{1}{0}", "\"", objPelatihan.TglPelatihan.Value.ToString("dd/MM/yyyy"));
                sbProject.Append(",");
                sbProject.AppendFormat("  {0}TempatPelatihan{0}:{0}{1}{0}", "\"", objPelatihan.TempatPelatihan);
                sbProject.Append(",");
                sbProject.AppendFormat("  {0}Pembicara{0}:{0}{1}{0}", "\"", objPembicara.NamaPembicara);
                sbProject.Append(",");
                sbProject.AppendFormat("  {0}TglPelatihanAkhir{0}:{0}{1}{0}", "\"", objPelatihan.TglAkhirPelatihan.Value.ToString("dd/MM/yyyy"));
                sbProject.Append("}");
                context.Response.Write(sbProject.ToString());
                

            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }

    }
}